<template>
  <div id="nav">

      <router-link to="/">音乐</router-link>
    |
      <router-link to="/about">壁纸</router-link>
    <audio id="music1" v-if="store.state.song" :src="  store.state.song.songUrl" loop autoplay />
  </div>

    <router-view v-slot="{ Component }">
      <transition>
        <keep-alive include="Home,About">
            <component :is="Component"></component>
        </keep-alive>
      </transition>
    </router-view>

</template>
<script setup>
import {provide} from 'vue'
import {useStore} from 'vuex'
const store = useStore()
const audio = document.getElementById('music1');



provide('plays',()=>{
  audio.play();
})
provide('pauses',()=>{
  audio.pause();
})


</script>
<style lang="less">
*{
  margin: 0;
  padding: 0;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>

